Full source code website bán hàng thương mại điện tử gần giống shopee
468.962 lượt xem;
1 <table height="28" cellSpacing="0" cellPadding="0" width="100%" border="0">
2 <tr align=center>
3 <td class="title" width="100%">Customers :  
4 </td>
5 </tr>
6 </table>
7 <?
8 switch ($_GET['action'])
9 {
10 case 'del' :
11 $id = $_GET['id'];
12 $sql = "delete from customers where customers_id='".$id."'";
13 $result = mysql_query($sql,$con);
14 echo mysql_error();
15 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
16 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
17 break;
18 }
19 ?>
20
21 <?
22 if (isset($_POST['ButDel'])) {
23 $cnt=0;
24 foreach ($_POST['chk'] as $id)
25 {
26 @$result = mysql_query("delete from customers where customers_id='".$id."'",$con);
27 if ($result) $cnt++;
28 }
29 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
30 }
31 ?>
32
33 <form action="index.php" method="POST" name="frmList">
34 <input type=hidden name="page" value="<? echo $page; ?>">
35 <?
36 function taotrang($sql,$link,$nitem,$itemcurrent)
37 { global $con;
38 $ret="";
39 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
40 $value = mysql_fetch_array($result);
41 $plus = (($value['cnt'] % $nitem)>0);
42 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
43 {
44 if ($i+1<>$itemcurrent) $ret .= "<a href=\"".$link.($i+1)."\" class=\"lslink\">".($i+1)."</a> ";
45 else $ret .= ($i+1)." ";
46 }
47 return $ret;
48 }
49 $pageindex=taotrang("select count(*) from customers","./?act=customer"."&page=",20,$page);
50 ?>
51
52 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
53 <tr>
54 <td class="smallfont" colspan="11">Trang : <? echo $pageindex; ?></td>
55 </tr>
56 </table>
57
58 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
59 <tr>
60 <td width="1%" align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
61 <td width="1%" colspan="2" nowrap class="title"> </td>
62 <td width="4%" align="center" nowrap class="title"><b>ID</b></td>
63 <td width="10%" align="center" nowrap class="title"><b>Name</b></td>
64 <td width="20%" align="center" nowrap class="title"><b>Sex</b></td>
65 <td width="10%" align="center" nowrap class="title"><b>Company</b></td>
66 <td width="10%" align="center" nowrap class="title"><b>Address</b></td>
67 <td width="20%" align="center" nowrap class="title"><b>City</b></td>
68 <td width="20%" align="center" nowrap class="title"><b>State</b></td>
69 <td width="20%" align="center" nowrap class="title"><b>Country</b></td>
70 <td width="20%" align="center" nowrap class="title"><b>Phone</b></td>
71 <td width="20%" align="center" nowrap class="title"><b>Email</b></td>
72 <td width="20%" align="center" nowrap class="title"><b>Fax</b></td>
73 <td width="20%" align="center" nowrap class="title"><b>Website</b></td>
74 <td width="20%" align="center" nowrap class="title"><b>Username</b></td>
75 <td width="20%" align="center" nowrap class="title"><b>Password</b></td>
76 <td width="20%" align="center" nowrap class="title"><b>Date</b></td>
77 </tr>
78
79 <?php
80 $page = $_GET["page"];
81 $sql="select * from customers order by customers_date_added desc";
82 $result=mysql_query($sql,$con);
83 $i=0;
84 @mysql_data_seek($result,($page-1)*20);
85 while(($row=mysql_fetch_array($result)) && $i<20)
86 {
87 $i++;
88 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
89 ?>
90
91 <tr>
92 <td bgcolor="<? echo $color; ?>" width="1%" class="smallfont">
93 <p align="center"><input type="checkbox" name="chk[]" value="<? echo $row['customers_id']; ?>"></td>
94 <td bgcolor="<? echo $color; ?>" width="1%" class="smallfont">
95 <p align="center">
96 <!--<a href="./?act=product_m&id=<? echo $row['products_id']; ?>&page=<? echo $page?>">Edit</a></td>-->
97 <td bgcolor="<? echo $color; ?>" width="4%" class="smallfont">
98 <p align="center">
99 <a onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" href="./?act=customer&action=del&id=<? echo $row['customers_id']; ?>">Delete</a></td>
100 <td bgcolor="<? echo $color; ?>" width="10%" align="left" width="55" align="left" class="smallfont"><? echo $row['customers_id']; ?> </td>
101 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_name']; ?> </td>
102 <td bgcolor="<? echo $color; ?>" width="10%" class="smallfont"><? echo $row['customers_sex']; ?> </td>
103 <td bgcolor="<? echo $color; ?>" width="10%" class="smallfont"><? echo $row['customers_company']; ?> </td>
104 <td bgcolor="<? echo $color; ?>" width="10%" class="smallfont"><? echo $row['customers_address']; ?> </td>
105 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_city']; ?> </td>
106 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_state']; ?> </td>
107 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_country']; ?> </td>
108 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_phone']; ?> </td>
109 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_email']; ?> </td>
110 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_fax']; ?> </td>
111 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_website']; ?> </td>
112 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_username']; ?> </td>
113 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_password']; ?> </td>
114 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_date_added']; ?> </td>
115 </tr>
116 <?
117 }
118 ?>
119 </table>
120 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button">
121 <input type="hidden" name="act" value="customer">
122 </form>
123 <script language="JavaScript">
124 function chkallClick(o) {
125 var form = document.frmList;
126 for (var i = 0; i < form.elements.length; i++) {
127 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
128 form.elements[i].checked = document.frmList.chkall.checked;
129 }
130 }
131 }
132 </script>
2 <tr align=center>
3 <td class="title" width="100%">Customers :  
4 </td>
5 </tr>
6 </table>
7 <?
8 switch ($_GET['action'])
9 {
10 case 'del' :
11 $id = $_GET['id'];
12 $sql = "delete from customers where customers_id='".$id."'";
13 $result = mysql_query($sql,$con);
14 echo mysql_error();
15 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
16 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
17 break;
18 }
19 ?>
20
21 <?
22 if (isset($_POST['ButDel'])) {
23 $cnt=0;
24 foreach ($_POST['chk'] as $id)
25 {
26 @$result = mysql_query("delete from customers where customers_id='".$id."'",$con);
27 if ($result) $cnt++;
28 }
29 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
30 }
31 ?>
32
33 <form action="index.php" method="POST" name="frmList">
34 <input type=hidden name="page" value="<? echo $page; ?>">
35 <?
36 function taotrang($sql,$link,$nitem,$itemcurrent)
37 { global $con;
38 $ret="";
39 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
40 $value = mysql_fetch_array($result);
41 $plus = (($value['cnt'] % $nitem)>0);
42 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
43 {
44 if ($i+1<>$itemcurrent) $ret .= "<a href=\"".$link.($i+1)."\" class=\"lslink\">".($i+1)."</a> ";
45 else $ret .= ($i+1)." ";
46 }
47 return $ret;
48 }
49 $pageindex=taotrang("select count(*) from customers","./?act=customer"."&page=",20,$page);
50 ?>
51
52 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
53 <tr>
54 <td class="smallfont" colspan="11">Trang : <? echo $pageindex; ?></td>
55 </tr>
56 </table>
57
58 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
59 <tr>
60 <td width="1%" align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
61 <td width="1%" colspan="2" nowrap class="title"> </td>
62 <td width="4%" align="center" nowrap class="title"><b>ID</b></td>
63 <td width="10%" align="center" nowrap class="title"><b>Name</b></td>
64 <td width="20%" align="center" nowrap class="title"><b>Sex</b></td>
65 <td width="10%" align="center" nowrap class="title"><b>Company</b></td>
66 <td width="10%" align="center" nowrap class="title"><b>Address</b></td>
67 <td width="20%" align="center" nowrap class="title"><b>City</b></td>
68 <td width="20%" align="center" nowrap class="title"><b>State</b></td>
69 <td width="20%" align="center" nowrap class="title"><b>Country</b></td>
70 <td width="20%" align="center" nowrap class="title"><b>Phone</b></td>
71 <td width="20%" align="center" nowrap class="title"><b>Email</b></td>
72 <td width="20%" align="center" nowrap class="title"><b>Fax</b></td>
73 <td width="20%" align="center" nowrap class="title"><b>Website</b></td>
74 <td width="20%" align="center" nowrap class="title"><b>Username</b></td>
75 <td width="20%" align="center" nowrap class="title"><b>Password</b></td>
76 <td width="20%" align="center" nowrap class="title"><b>Date</b></td>
77 </tr>
78
79 <?php
80 $page = $_GET["page"];
81 $sql="select * from customers order by customers_date_added desc";
82 $result=mysql_query($sql,$con);
83 $i=0;
84 @mysql_data_seek($result,($page-1)*20);
85 while(($row=mysql_fetch_array($result)) && $i<20)
86 {
87 $i++;
88 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
89 ?>
90
91 <tr>
92 <td bgcolor="<? echo $color; ?>" width="1%" class="smallfont">
93 <p align="center"><input type="checkbox" name="chk[]" value="<? echo $row['customers_id']; ?>"></td>
94 <td bgcolor="<? echo $color; ?>" width="1%" class="smallfont">
95 <p align="center">
96 <!--<a href="./?act=product_m&id=<? echo $row['products_id']; ?>&page=<? echo $page?>">Edit</a></td>-->
97 <td bgcolor="<? echo $color; ?>" width="4%" class="smallfont">
98 <p align="center">
99 <a onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" href="./?act=customer&action=del&id=<? echo $row['customers_id']; ?>">Delete</a></td>
100 <td bgcolor="<? echo $color; ?>" width="10%" align="left" width="55" align="left" class="smallfont"><? echo $row['customers_id']; ?> </td>
101 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_name']; ?> </td>
102 <td bgcolor="<? echo $color; ?>" width="10%" class="smallfont"><? echo $row['customers_sex']; ?> </td>
103 <td bgcolor="<? echo $color; ?>" width="10%" class="smallfont"><? echo $row['customers_company']; ?> </td>
104 <td bgcolor="<? echo $color; ?>" width="10%" class="smallfont"><? echo $row['customers_address']; ?> </td>
105 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_city']; ?> </td>
106 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_state']; ?> </td>
107 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_country']; ?> </td>
108 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_phone']; ?> </td>
109 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_email']; ?> </td>
110 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_fax']; ?> </td>
111 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_website']; ?> </td>
112 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_username']; ?> </td>
113 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_password']; ?> </td>
114 <td bgcolor="<? echo $color; ?>" width="20%" class="smallfont"><? echo $row['customers_date_added']; ?> </td>
115 </tr>
116 <?
117 }
118 ?>
119 </table>
120 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button">
121 <input type="hidden" name="act" value="customer">
122 </form>
123 <script language="JavaScript">
124 function chkallClick(o) {
125 var form = document.frmList;
126 for (var i = 0; i < form.elements.length; i++) {
127 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
128 form.elements[i].checked = document.frmList.chkall.checked;
129 }
130 }
131 }
132 </script>